/* GUI CONVERTED from sqqomta.p (converter v1.76) Tue Nov 12 14:45:04 2002 */
/* sqqomta.p - QUOTE MAINTENANCE LINE ITEMS                                   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.34 $                                                          */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 4.0      LAST MODIFIED: 12/09/88   BY: jms *A548*                */
/* REVISION: 6.0      LAST MODIFIED: 03/21/90   BY: ftb *D011*                */
/* REVISION: 6.0      LAST MODIFIED: 03/22/90   BY: ftb *D007*                */
/* REVISION: 5.0      LAST MODIFIED: 04/04/90   BY: MLB *B586*                */
/* REVISION: 6.0      LAST MODIFIED: 04/09/90   BY: ftb *D002*                */
/* REVISION: 5.0      LAST MODIFIED: 04/27/90   BY: MLB *B680*                */
/* REVISION: 6.0      LAST MODIFIED: 05/16/90   BY: MLB *D021*                */
/* REVISION: 5.0      LAST MODIFIED: 07/04/90   BY: MLB *B726*                */
/* REVISION: 6.0      LAST MODIFIED: 08/09/90   BY: MLB *D055*                */
/* REVISION: 6.0      LAST MODIFIED: 12/21/90   BY: MLB *D238*                */
/* REVISION: 6.0      LAST MODIFIED: 05/28/91   BY: emb *D663*                */
/* REVISION: 6.0      LAST MODIFIED: 06/06/91   BY: MLV *D674*                */
/* REVISION: 6.0      LAST MODIFIED: 08/14/91   BY: MLV *D825*                */
/* REVISION: 7.0      LAST MODIFIED: 09/17/91   BY: MLV *F015*                */
/* REVISION: 7.0      LAST MODIFIED: 09/25/91   BY: pma *F003*                */
/* REVISION: 6.0      LAST MODIFIED: 11/18/91   BY: afs *D934*                */
/* REVISION: 7.0      LAST MODIFIED: 02/21/92   BY: afs *F223*                */
/* REVISION: 7.0      LAST MODIFIED: 03/05/92   BY: tjs *F247*                */
/* REVISION: 7.0      LAST MODIFIED: 03/23/92   BY: pma *F307*                */
/* REVISION: 7.0      LAST MODIFIED: 03/24/92   BY: pma *F089*                */
/* REVISION: 7.0      LAST MODIFIED: 04/11/92   BY: afs *F356*                */
/* REVISION: 7.0      LAST MODIFIED: 04/15/92   BY: dld *F382*                */
/* REVISION: 7.0      LAST MODIFIED: 05/13/92   BY: tjs *F464*                */
/* REVISION: 7.0      LAST MODIFIED: 06/16/92   BY: afs *F519*                */
/* REVISION: 7.0      LAST MODIFIED: 06/26/92   BY: afs *F710*                */
/* REVISION: 7.0      LAST MODIFIED: 07/22/92   BY: tjs *F800*                */
/* REVISION: 7.3      LAST MODIFIED: 09/22/92   BY: tjs *G035*                */
/* REVISION: 7.3      LAST MODIFIED: 09/23/92   BY: tjs *G086*                */
/* REVISION: 7.3      LAST MODIFIED: 11/05/92   BY: afs *G244*                */
/* REVISION: 7.3      LAST MODIFIED: 12/15/92   BY: afs *G447*                */
/* REVISION: 7.3      LAST MODIFIED: 01/17/93   BY: afs *G501*                */
/* REVISION: 7.3      LAST MODIFIED: 01/21/93   BY: tjs *G579*                */
/* REVISION: 7.3      LAST MODIFIED: 01/29/93   BY: bcm *G414*                */
/* REVISION: 7.3      LAST MODIFIED: 02/02/93   BY: tjs *G620*                */
/* REVISION: 7.3      LAST MODIFIED: 04/05/93   BY: bcm *G889*                */
/* REVISION: 7.3      LAST MODIFIED: 04/08/93   BY: tjs *G830*                */
/* REVISION: 7.4      LAST MODIFIED: 06/06/93   BY: wep *H005*                */
/* REVISION: 7.4      LAST MODIFIED: 07/02/93   BY: dpm *H016*                */
/* REVISION: 7.4      LAST MODIFIED: 10/10/93   BY: cdt *H086*                */
/* REVISION: 7.4      LAST MODIFIED: 10/02/93   BY: cdt *H184*                */
/* REVISION: 7.4      LAST MODIFIED: 11/03/93   BY: bcm *H206*                */
/* REVISION: 7.4      LAST MODIFIED: 11/22/93   BY: afs *H238*                */
/* REVISION: 7.4      LAST MODIFIED: 02/04/94   BY: dpm *GI46*                */
/* REVISION: 7.4      LAST MODIFIED: 04/14/94   BY: afs *GJ39*                */
/* REVISION: 7.3      LAST MODIFIED: 04/21/94   BY: WUG *GJ54*                */
/* REVISION: 7.4      LAST MODIFIED: 07/05/94   BY: tjs *FN95*                */
/* REVISION: 7.3      LAST MODIFIED: 06/22/94   BY: WUG *GK60*                */
/* REVISION: 7.4      LAST MODIFIED: 07/08/94   BY: bcm *H437*                */
/* REVISION: 7.4      LAST MODIFIED: 07/11/94   BY: bcm *H438*                */
/* REVISION: 7.4      LAST MODIFIED: 09/15/94   by: slm *GM62*                */
/* REVISION: 7.4      LAST MODIFIED: 09/22/94   by: JPM *GM78*                */
/* REVISION: 7.4      LAST MODIFIED: 10/16/94   by: dpm *FR95*                */
/* REVISION: 7.4      LAST MODIFIED: 11/01/94   BY: ame *GN94*                */
/* REVISION: 7.4      LAST MODIFIED: 11/03/94   BY: afs *H587*                */
/* REVISION: 7.4      LAST MODIFIED: 11/08/94   BY: rwl *GO31*                */
/* REVISION: 8.5      LAST MODIFIED: 11/29/94   BY: mwd *J034*                */
/* REVISION: 7.4      LAST MODIFIED: 01/28/95   BY: rwl *G0D7*                */
/* REVISION: 7.4      LAST MODIFIED: 02/23/95   BY: jzw *H0BM*                */
/* REVISION: 7.4      LAST MODIFIED: 03/29/95   BY: rxm *F0PJ*                */
/* REVISION: 7.4      LAST MODIFIED: 03/29/95   BY: dzn *F0PN*                */
/* REVISION: 8.5      LAST MODIFIED: 03/22/95   BY: jlf *J042*                */
/* REVISION: 7.4      LAST MODIFIED: 06/09/95   BY: rxm *G0PH*                */
/* REVISION: 7.4      LAST MODIFIED: 10/12/95   BY: ais *G0Z8*                */
/* REVISION: 8.5      LAST MODIFIED: 11/07/95   BY: taf *J053*                */
/* REVISION: 8.5      LAST MODIFIED: 05/22/96   BY: DAH *J0N2*                */
/* REVISION: 8.5      LAST MODIFIED: 06/22/96   BY: RUW *J0P8*                */
/* REVISION: 8.5      LAST MODIFIED: 06/27/96   BY: ajw *J0V2*                */
/* REVISION: 8.5      LAST MODIFIED: 07/04/96   BY: DAH *J0XR*                */
/* REVISION: 8.5      LAST MODIFIED: 07/15/96   BY: ajw *J0Z6*                */
/* REVISION: 8.5      LAST MODIFIED: 09/18/96   BY: *G2F7* Sanjay Patil       */
/* REVISION: 8.6      LAST MODIFIED: 09/26/96   BY: *K007* Srinivasa Sharapady*/
/* REVISION: 8.6      LAST MODIFIED: 12/31/96   BY: *K03Y* Jean Miller        */
/* REVISION: 8.6      LAST MODIFIED: 02/15/97   BY: *J1L2* Suresh Nayak       */
/* REVISION: 8.6      LAST MODIFIED: 02/21/97   BY: *H0SM* Suresh Nayak       */
/* REVISION: 8.6      LAST MODIFIED: 12/08/97   BY: *K1BP* Val Portugal       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* Annasaheb Rahane   */
/* REVISION: 8.6E     LAST MODIFIED: 03/24/98   BY: *J2FG* Niranjan Ranka     */
/* REVISION: 8.6E     LAST MODIFIED: 05/11/98   BY: *J2L3* Niranjan Ranka     */
/* REVISION: 8.6E     LAST MODIFIED: 06/11/98   BY: *L01S* Russ Witt          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.0      LAST MODIFIED: 11/24/98   BY: *M017* David Morris       */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Patti Gaultney     */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 06/30/00   BY: *N0DX* BalbeerS Rajput    */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 11/03/00   BY: *L15F* Kaustubh Kulkarni  */
/* REVISION: 9.1      LAST MODIFIED: 09/29/00   BY: *N0WC* Mudit Mehta        */
/* Revision: 1.28         BY: Katie Hilbert       DATE: 04/01/01  ECO: *P002* */
/* Revision: 1.29         BY: Russ Witt           DATE: 06/04/01  ECO: *P00J* */
/* Revision: 1.33         BY: Jean Miller         DATE: 04/19/02  ECO: *P05M* */
/* $Revision: 1.34 $      BY: Robin McCarthy      DATE: 11/08/02  ECO: *P0JS* */
/* Revision: EB2 SP3       BY: Kaine Zhang        DATE: 10/31/03  *hk-s-026** */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdeclre.i}
{cxcustom.i "SQQOMTA.P"}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

{&SQQOMTA-P-TAG1}

/* DEFINE RNDMTHD FOR CALL TO SQQOMTLA.P */
define shared variable rndmthd       like rnd_rnd_mthd.
define shared variable line          like qod_line.
define shared variable del-yn        like mfc_logical.
define shared variable prev_due      like qod_due_date.
define shared variable prev_qty_ord  like qod_qty_quot.
define shared variable part          as character format "x(18)".
define shared variable qo_recno      as recid.
define shared variable promise_date  as date label "Promise Date".
define shared variable rsn_lost      like qod_rsn_lost.
define shared variable qoclcmmts     like mfc_logical.
define shared variable sngl_ln       like soc_ln_fmt.
define shared variable tax_in        like cm_tax_in.
define shared variable qoc_pc_line   like mfc_logical.
define shared variable qocrt_int     like qod_crt_int.
define shared variable reprice       like mfc_logical.
define shared variable line_pricing  like mfc_logical.
define shared variable new_order     like mfc_logical.
define shared variable cfexists      like mfc_logical.
define shared variable cf_cfg_path   like mfc_char.
define shared variable cf_chr        as character.

define new shared variable pcqty     like qod_qty_quot.
define new shared variable qod_recno as recid.
define new shared variable cmtindx   like cmt_indx.
define new shared variable desc1     like pt_desc1.
define new shared variable qodcmmts  like soc_lcmmts label "Comments".
define new shared variable newline   like mfc_logical.
define new shared variable clines    as integer initial ?.
define new shared variable prev_site like qod_site.

define new shared variable sqqomtla_error like mfc_logical initial true.
define new shared variable new_site like sod_site.
define new shared variable err_stat as integer.
define new shared variable new_line like mfc_logical.
define new shared variable discount as decimal label "Discount"
   format "->>>9.9<<<".

define new shared variable reprice_dtl      like mfc_logical label "Reprice".
define new shared variable save_parent_list like sod_list_pr.
define new shared variable cf_pm_code       like pt_pm_code.
define new shared variable cf_pt_part_o     like pt_part.
define new shared variable cf_pt_part_n     like pt_part  no-undo.
define new shared variable cf_line          like sod_line no-undo.
define new shared variable cf_rp_part       like mfc_logical no-undo.
define new shared variable cf_endcfg        like mfc_logical no-undo.
define new shared variable original_model   as character format "x(40)".

define variable i as integer.
define variable prev_abnormal   like qod_abnormal.
define variable l_sngl_ln       like soc_ln_fmt no-undo.
define variable yn              like mfc_logical.
define variable first_time      like mfc_logical initial yes.
define variable qty_allocatable like in_qty_avail label "Qty Allocatable".
define variable ptstatus        like pt_status.
define variable x3              as character format "x(3)".
define variable disc_min_max    like mfc_logical.
define variable disc_pct_err    as decimal.
define variable l_part          like pt_part no-undo.
define variable mc-error-number like msg_nbr no-undo.
define variable apm-ex-sub      as character format "x(24)" no-undo.
define variable error_flag      like mfc_logical         no-undo.
define variable err_mess_no     like msg_nbr             no-undo.
define variable cust-resv-loc   like locc_loc            no-undo.
define variable useloc          like mfc_logical         no-undo.
define variable use-log-acctg   as logical               no-undo.

define new shared frame c.
define new shared frame d.
define new shared frame c_site.
{&SQQOMTA-P-TAG2}

for first qo_mstr
   fields(qo_curr qo_cust qo_due_date qo_ex_rate qo_ex_rate2
          qo_fix_rate qo_fr_list qo_nbr qo_ord_date qo_pricing_dt
          qo_project qo_pr_list qo_pst qo_req_date qo_ship qo_site
          qo_taxable qo_taxc qo_tax_env qo_tax_usage qo__qad03)
   where recid(qo_mstr) = qo_recno
no-lock: end.

find first soc_ctrl no-lock.
find first qoc_ctrl no-lock.
find first pic_ctrl no-lock.

/* CHECK IF LOGISTICS ACCOUNTING IS ENABLED */
{gprun.i ""lactrl.p"" "(output use-log-acctg)"}
/*GUI*/ if global-beam-me-up then undo, leave.



/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(1)
   qo_nbr qo_cust sngl_ln
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* DEFINE FORMS */
{sqlinfrm.i}
{&SQQOMTA-P-TAG3}

/*V8:HiddenDownFrame=c */
linefmt:
repeat on endkey undo, leave:
/*GUI*/ if global-beam-me-up then undo, leave.


   assign l_sngl_ln = sngl_ln.
   {&SQQOMTA-P-TAG4}
   if not first_time then do:
   {&SQQOMTA-P-TAG5}
      update sngl_ln with frame a.
   end.

   if l_sngl_ln <> sngl_ln  then
      clear frame c all no-pause.

   display qo_nbr qo_cust sngl_ln with frame a.
   clines = ?.
   if sngl_ln then clines = 1.
   first_time = no.

   {&SQQOMTA-P-TAG6}
   mainloop:
   repeat with frame c on endkey undo, next linefmt:
/*GUI*/ if global-beam-me-up then undo, leave.


      find first qo_mstr where recid(qo_mstr) = qo_recno
      exclusive-lock no-error.

      reprice_dtl = reprice.

      display
         qo_nbr
         qo_cust
         sngl_ln
      with frame a.

      hide frame c.
      hide frame d.
      view frame c.
      if sngl_ln then view frame d.

      qodcmmts = qoclcmmts.

      /* SCREENS & REPORTS DON'T SUPPORT 4 DIGIT LINE NOS. */
      if line < 999 then
         line = line + 1.
      else
         if line = 999 then do:
         {pxmsg.i &MSGNUM=7418 &ERRORLEVEL=2}  /* LINE CANNOT BE > 999 */
      end.

      find qod_det where qod_nbr = qo_nbr and qod_line = line
      no-lock no-error.

      if not available qod_det then do:

         discount = if pic_qo_fact then 1
                    else 0.
         display
            line
            "" @ qod_part
            0  @ qod_qty_quot
            "" @ qod_um
            0  @ qod_list_pr
            discount
            0  @ qod_price
         with frame c.

      end.

      if available qod_det then do:

         display
            line
            qod_part
            qod_qty_quot
            qod_um
            qod_price
         with frame c.

         if qod_type = "" then do:
            find pt_mstr where pt_part = qod_part no-lock no-error no-wait.
            if available pt_mstr then
               desc1 = pt_desc1.
            else if qod_desc <> "" then
               desc1 = qod_desc.
            else
               desc1 = getTermLabel("ITEM_NOT_IN_INVENTORY", 24).
         end.
         else
            desc1 = qod_desc.

         if sngl_ln then
         display
            desc1
            qod_acct
            qod_sub
            qod_cc
            qod_site
            qod_loc
            qod_dsc_acct
            qod_dsc_sub
            qod_dsc_cc
            qod_dsc_project
            qod_serial
            qod_project
            qod_type
            qod_pricing_dt
            qod_rel_chg
            qod_req_date
            qod_um_conv
            qod_qty_rel
            qod_per_date
            qod_rsn_lost
            qod_due_date
            qod_taxable
            qod_taxc
            qod_fr_list
            qod_std_cost
            (qod_cmtindx <> 0 ) @ qodcmmts
            qod_crt_int
            qod_fix_pr
         with frame d.

      end.

      display line with frame c.

      if not cf_rp_part then do:

         update line with frame c
         editing:

            /* FIND NEXT RECORD */
            {mfnp01.i qod_det line qod_line qo_nbr qod_nbr qod_nbrln}

            if recno <> ? then do:
               line = qod_line.
               /*DETERMINE DISCOUNT DISPLAY FORMAT AND SET VARIABLE discount*/
               {gppidisc.i pic_qo_fact qod_disc_pct pic_qo_rfact}
               display line qod_part qod_qty_quot qod_um
                  qod_list_pr discount
                  qod_price with frame c.
               find pt_mstr where pt_part = qod_part no-lock no-error
                  no-wait.
               if qod_type = "" then do:
                  if available pt_mstr then desc1 = pt_desc1.
                  else if qod_desc <> "" then desc1 = qod_desc.
                  else desc1 = getTermLabel("ITEM_NOT_IN_INVENTORY", 24).
               end.
               else desc1 = qod_desc.
               if sngl_ln then
               display
                  desc1
                  qod_acct
                  qod_sub
                  qod_cc
                  qod_site
                  qod_loc
                  qod_dsc_acct
                  qod_dsc_sub
                  qod_dsc_cc
                  qod_dsc_project
                  qod_serial
                  qod_project
                  qod_type
                  qod_pricing_dt
                  qod_rel_chg
                  qod_req_date
                  qod_um_conv
                  qod_qty_rel
                  qod_per_date
                  qod_rsn_lost
                  qod_due_date
                  qod_taxable
                  qod_taxc
                  qod_fr_list
                  qod_std_cost
                  (qod_cmtindx <> 0 ) @ qodcmmts
                  qod_crt_int
                  qod_fix_pr
               with frame d.
            end.

         end. /* editing line */

      end. /* if not cf_rp_part*/
      if cf_rp_part then do:
         line = cf_line.
         display line with frame c.
      end.

      /* ADD/MOD/DELETE  */
      newline = no.

      find qod_det where qod_nbr = qo_nbr
                     and qod_line = input line
      no-error.

      if not available qod_det then do:

         if line = 0 then do:
            {pxmsg.i &MSGNUM=642 &ERRORLEVEL=4} /* Invalid line number */
            undo mainloop, retry.
         end.

         if not new_order then
            reprice_dtl = yes.  /*This will cause the line to be priced*/

         create qod_det.
         assign
            qod_nbr            = qo_nbr
            qod_line           = input line
            qod_due_date       = qo_due_date
            qod_pricing_dt     = qo_pricing_dt
            qod__chr01         = qo_pr_list
            qod_req_date       = qo_req_date
            qod_rsn_lost       = rsn_lost
            qod_per_date       = promise_date
            qod_site           = qo_site
            qod_project        = qo_project
            qod_dsc_project    = qo_project
            qod_fr_list        = qo_fr_list
            qod_crt_int        = qocrt_int
            qod_bonus          = no
            qodcmmts           = qoc_lcmmts .

         if qo__qad03 = 2 then
            assign qod_fix_pr = yes.
         else
         if qo__qad03 = 1 then
            assign qod_fix_pr = no.
         else
         if qo__qad03 = 0 then
            assign qod_fix_pr = qo_fix_rate.

         new_line = true.
         if recid(qod_det) = -1 then .

         /* INITIALIZE TAX MANAGEMENT FIELDS */
         assign
            qod_taxable   = qo_taxable
            qod_taxc      = qo_taxc
            qod_tax_usage = qo_tax_usage
            qod_tax_env   = qo_tax_env
            qod_tax_in    = tax_in.

         assign line.
         desc1 = "".
         newline = yes.

         /*DETERMINE DISCOUNT DISPLAY FORMAT AND SET VARIABLE discount*/
         {gppidisc.i pic_qo_fact qod_disc_pct pic_qo_rfact}

         display
            line
            qod_part
            qod_qty_quot
            qod_um
            qod_list_pr
            discount
            qod_price
         with frame c.

         if sngl_ln then
         display
            desc1
            qod_acct
            qod_sub
            qod_cc
            qod_site
            qod_loc
            qod_dsc_acct
            qod_dsc_sub
            qod_dsc_cc
            qod_dsc_project
            qod_serial
            qod_project
            qod_type
            qod_pricing_dt
            qod_rel_chg
            qod_req_date
            qod_um_conv
            qod_qty_rel
            qod_per_date
            qod_rsn_lost
            qod_due_date
            qod_taxable
            qod_taxc
            qod_fr_list
            qod_std_cost
            qodcmmts
            qod_crt_int
            qod_fix_pr
         with frame d.

         if not cf_rp_part then do:

            prompt-for qod_part with frame c
            editing:

               /* FIND NEXT/PREVIOUS  RECORD */
               {mfnp.i pt_mstr qod_part pt_part qod_part pt_part pt_part}

               if recno <> ? then do:
                  assign
                     desc1    = pt_desc1
                     qod_part = pt_part
                     qod_um   = pt_um .

                  /* CONVERT FROM BASE TO FOREIGN CURRENCY */
                  {gprunp.i "mcpl" "p" "mc-curr-conv"
                     "(input base_curr,
                       input qo_curr,
                       input qo_ex_rate2,
                       input qo_ex_rate,
                       input pt_price,
                       input false, /* DO NOT ROUND */
                       output qod_price,
                       output mc-error-number)"}.

                  qod_list_pr = qod_price.

                  display
                     qod_part
                     qod_um
                     qod_list_pr
                     qod_price
                  with frame c.

                  if sngl_ln then display desc1 with frame d.

               end.

            end.

         end. /* if not cf_rp_part*/

         if cf_rp_part then do:
            qod_part = cf_pt_part_n.
            display qod_part with frame c.
         end.

         if not cf_rp_part then
            assign qod_part.

         l_part = qod_part.

         /* SEARCH CUSTOMER ITEM/ ITEM MASTER */
         {gprun.i ""sopart.p"" "(input qo_cust,
                                 input qo_ship,
                                 input-output qod_part,
                                 output qod_custpart)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         for first pt_mstr
            fields (pt_desc1 pt_fr_class pt_loc pt_part pt_pm_code
                    pt_price pt_prod_line pt_ship_wt pt_ship_wt_um
                    pt_site pt_status pt_taxable pt_taxc pt_um )
            where pt_part = qod_part
         no-lock: end.

         if l_part <> qod_part then do:
            display qod_part with frame c.
            /* CUSTOMER ITEM # REPLACED BY # */
            {pxmsg.i &MSGNUM=56 &ERRORLEVEL=1
                     &MSGARG1=l_part
                     &MSGARG2=qod_part}
         end. /* IF L_PART <> QOD_PART */

         if available pt_mstr and pt_pm_code = "F"
         then do with frame c:

            part = qod_part.

            /* SCROLLING WINDOW FOR FAMILY ITEMS, WAS SWBOM */
            {gprun.i ""sosobom.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


            if part > "" then qod_part = part.

            display part @ qod_part.

            for first pt_mstr
               fields (pt_desc1 pt_fr_class pt_loc pt_part pt_pm_code
                       pt_price pt_prod_line pt_ship_wt pt_ship_wt_um
                       pt_site pt_status pt_taxable pt_taxc pt_um )
               where pt_part = qod_part
            no-lock: end.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* IF AVAILABLE PT_MSTR AND PT_PM_CODE = "F" */

         /* MOVED THE LOGIC FOR PT_MSTR/CP_MSTR SEARCH TO SOPART.P */
         for first cm_mstr
            fields(cm_addr cm_promo)
            where cm_addr = qo_cust
         no-lock: end.
/*GUI*/ if global-beam-me-up then undo, leave.


         if available cm_mstr then do:
            if soc_apm and cm_promo <> "" then do:
               if available pt_mstr then do:
                  /* CHECK IF PART BELONGS TO AN APM DIVISION */
                  apm-ex-sub = "if/".
                  {gprunex.i
                     &module  = 'APM'
                     &subdir  = apm-ex-sub
                     &program = 'ifapm001.p'
                     &params  = "(input qod_part,
                                  input qo_div,
                                  output error_flag,
                                  output err_mess_no)"}
                  if error_flag then do:
                     /* ITEM # LINE# DOES NOT BELONG TO APM DIVISION */
                     {pxmsg.i &MSGNUM=err_mess_no &ERRORLEVEL=3
                              &MSGARG1=qod_part
                              &MSGARG2=qo_div}
                     undo, next.
                  end.

                  /* CONFIGURED PART - CHECK COMPONENTS */
                  if pt_pm_code = "C" then do:

                     for each ps_mstr where ps_par = qod_part
                     no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


                        apm-ex-sub = "if/".
                        {gprunex.i
                           &module  = 'APM'
                           &subdir  = apm-ex-sub
                           &program = 'ifapm001.p'
                           &params  = "(input ps_comp,
                                        input qo_div,
                                        output error_flag,
                                        output err_mess_no)"}

                        if error_flag then do:
                           /* COMPONENT # DOES NOT BELONG TO APM DIVISION */
                           {pxmsg.i &MSGNUM=4543 &ERRORLEVEL=3
                                    &MSGARG1=ps_comp
                                    &MSGARG2=qo_div}
                           undo, leave.
                        end.

                     end.
/*GUI*/ if global-beam-me-up then undo, leave.


                     if error_flag then undo, next.

                  end. /* if pt_pm_code = C */

               end.

               qod_div = qo_div.

            end.  /* IF SOC_APM AND CM_PROMO <> "" */

         end.  /* IF AVAILABLE CM_MSTR */

         if available pt_mstr then do:

            /* INITIALIZE FREIGHT VALUES*/
            assign
               qod_fr_class = pt_fr_class
               qod_fr_wt    = pt_ship_wt
               qod_fr_wt_um = pt_ship_wt_um
               ptstatus = pt_status
               substring(ptstatus,9,1) = "#".

            if can-find(isd_det where isd_status = ptstatus
                                  and isd_tr_type = "ADD-SQ")
            then do:
               {pxmsg.i &MSGNUM=358 &ERRORLEVEL=3 &MSGARG1=pt_status}
               undo, retry.
            end.

            /*  Set line item tax flags */
            assign
               qod_taxable = (qo_taxable and pt_taxable)
               qod_taxc = pt_taxc
               qod_prodline = pt_prod_line.

            /* SEE IF THERE IS A DEFAULT LOCATION FOR A  */
            /* CUSTOMER RESERVED LOCATION                */
            {gprun.i ""sorldft.p""
                     "(input qo_ship,
                       input qo_bill,
                       input qo_cust,
                       input qod_site,
                       output cust-resv-loc,
                       output useloc)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if useloc = yes then
               qod_loc = cust-resv-loc.
            else
               qod_loc  = pt_loc.

            /* NOTE: LEAVE QOD_SITE UNSET UNTIL AFTER DEFAULT CHECK */
            if qo_curr = base_curr then
            assign
               qod_price = pt_price
               qod_list_pr = pt_price.

            qod_um    = pt_um.
            qod_std_cost = 0.

            /* Set default line site to pt_mstr site if header site is */
            global_part = qod_part.
            if qod_type = "" then do:

               new_site = qod_site.
               {gprun.i ""gpptsi01.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


               if err_stat <> 0 then do:

                  new_site = pt_site.
                  {gprun.i ""gpptsi01.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if err_stat = 0 then do:

                     qod_site = pt_site.

                     /* Default site invalid; changed to Item default */
                     {pxmsg.i &MSGNUM=6201 &ERRORLEVEL=1 &MSGARG1=qod_site}

                     /* CHECK ITEM DEFAULT SITE */
                     {gprun.i ""gpsiver.p""
                        "(input pt_site, input ?, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                     if return_int = 0 then do:
                        if sngl_ln then do:
                           /* USER DOES NOT HAVE ACCESS TO DEFAULT SITE xxxx  */
                           {pxmsg.i &MSGNUM=2711 &ERRORLEVEL=2 &MSGARG1=pt_site}
                           qod_site = "".
                           display qod_site with frame d.
                        end.
                        else do:
                           /* USER DOES NOT HAVE ACCESS TO DEFAULT SITE xxxx  */
                           {pxmsg.i &MSGNUM=2711 &ERRORLEVEL=3 &MSGARG1=pt_site}
                           undo mainloop, retry.
                        end.
                     end.

                  end.
                  /* If multi-line, we need to reject the line NOW. */
                  else if not sngl_ln then do:
                     {pxmsg.i &MSGNUM=715 &ERRORLEVEL=3}
                     /* Item does not exist at site */
                     undo mainloop, retry.
                  end.
               end.
            end.

         end.  /* if available pt_mstr */
         /* Set the non-inventory flag now */
         else do:
            {pxmsg.i &MSGNUM=25 &ERRORLEVEL=2} /* Ship type set to (M)emo */
            qod_type = "M".
            if not sngl_ln and qo_site = "" then do:
               {pxmsg.i &MSGNUM=941 &ERRORLEVEL=3} /* BLANK SITE NOT ALLOWED */
               undo mainloop, retry.
            end.
         end.

      end.  /* new qod_det */
      /* Modifying existing line */
      else
         new_line = false.

      status input.
      line = qod_line.
      qod_recno = recid(qod_det).

      desc1 = getTermLabel("ITEM_NOT_IN_INVENTORY", 24).

      find pt_mstr where pt_part = qod_part no-lock no-error.

      if not available pt_mstr and qod_desc <> "" then
         desc1 = qod_desc.
      if available pt_mstr then
         desc1 = pt_desc1.
      else if qod_desc <> "" then
         desc1 = qod_desc.

      global_part = qod_part.

      if available pt_mstr then
         pt_recno = recid(pt_mstr).
      else
         pt_recno = 0.

      if not newline then
         qodcmmts = (qod_cmtindx <> 0).

      /*DETERMINE DISCOUNT DISPLAY FORMAT AND SET VARIABLE discount*/
      {gppidisc.i pic_qo_fact qod_disc_pct pic_qo_rfact}

      display
         line
         qod_part
         qod_qty_quot
         qod_um
         qod_list_pr
         discount
         qod_price
      with frame c.

      if sngl_ln then
      display
         desc1
         qod_acct
         qod_sub
         qod_cc
         qod_site
         qod_loc
         qod_dsc_acct
         qod_dsc_sub
         qod_dsc_cc
         qod_dsc_project
         qod_serial
         qod_project
         qod_type
         qod_pricing_dt
         qod_rel_chg
         qod_req_date
         qod_um_conv
         qod_qty_rel
         qod_per_date
         qod_rsn_lost
         qod_due_date
         qod_taxable
         qod_taxc
         qod_fr_list
         qod_std_cost
         qodcmmts
      with frame d.

      assign
         prev_due  = qod_due_date
         prev_qty_ord  = qod_qty_quot * qod_um_conv
         prev_abnormal = qod_abnormal
         del-yn = no.

      ststatus = stline[2].
      status input ststatus.

      /* Pause to show messages that will otherwise be hidden when */
      if sngl_ln and not batchrun then do:
         message.
         message.
      end.

/*hk-s-026*      {gprun.i ""sqqomtla.p""}  */
/*hk-s-026*/     {gprun.i ""xxsqqomtla.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      if sqqomtla_error then undo mainloop, retry.

      if del-yn = yes then do:
         /* The following code was duplicated in cfsqrbom.p */
         /* Make sure any modifications are also reviewed/made there */

         /* UPDATE ACCUM QTY WORKFILE WITH REVERSAL. save_parent_list
            DETERMINED IN sqqomtla.p*/
         if line_pricing or not new_order then do:
            {gprun.i ""gppiqty2.p""
               "(qod_line,
                 qod_part,
                 - qod_qty_quot,
                 - (qod_qty_quot * save_parent_list),
                 qod_um,
                 yes,
                 yes,
                 yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end.

         /* DELETE QUOTE LINE RELATED PRICE LIST HISTORY */
         {gprun.i ""gppihdel.p""
            "(2, qod_nbr, qod_line)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         for each sob_det where
            sob_nbr = "qod_det" + qod_nbr and
            sob_line = qod_line
         exclusive-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


            for each cmt_det exclusive-lock where cmt_indx = sob_cmtindx:
               delete cmt_det.
            end.

            /* UPDATE ACCUM QTY WORKFILE WITH REVERSAL, SINCE IT WAS INCLUDED */
            /* JUST PRIOR TO INVOKING sosomta.p */
            if line_pricing or not new_order then do:
               {gprun.i ""gppiqty2.p""
                  "(qod_line,
                    sob_part,
                    - (sob_qty_req / qod_um_conv),
                    - (sob_qty_req * sob_tot_std / qod_um_conv),
                    qod_um,
                    yes,
                    yes,
                    yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end.

            delete sob_det.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         /*DELETE COMMENTS*/
         for each cmt_det exclusive-lock where cmt_indx = qod_cmtindx:
            delete cmt_det.
         end.
         if cfexists and qod__qad01[1] <> "" then do:
            os-delete value(cf_cfg_path + cf_chr + qod__qad01[1]).
         end.

         /* DELETE QUOTE DETAIL RELATIONSHIPS */
         {gprun.i ""sqqoapm4.p"" "(input qod_nbr, input qod_line)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         /* IF LOGISTICS ACCOUNTING IS ENABLED */
         if use-log-acctg then do:

            /* DELETE LOGISTICS ACCOUNTING tx2d_det RECORDS FOR THIS LINE */
            {gprunmo.i &module = "LA" &program = "lataxdel.p"
                       &param  = """(input '40',
                                     input qod_nbr,
                                     input qod_line)"""}
         end.   /* use-log-acctg */

         delete qod_det.

         line = line - 1.
         del-yn = no.

         clear frame c.
         if sngl_ln then clear frame d.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.

         {pxmsg.i &MSGNUM=6 &ERRORLEVEL=1}
         next mainloop.

      end. /* if del_yn */

      find first sob_det where sob_nbr = "qod_det" + qod_nbr and
         sob_line = qod_line
      no-lock no-error.

      if available sob_det and
         (qod_site <> prev_site or qod_due_date <> prev_due)
      then do:
         qod_recno = recid(qod_det).
         /* UPDATE SOB SITE & ISSUE DATE */
         {gprun.i ""sqqomth.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      end.

      if not qod_bonus and soc_apm
         and available cm_mstr
         and cm_promo <> ""
      then
      for each pih_hist where
         pih_doc_type = 2 and
         pih_nbr      = qod_nbr and
         pih_line     = qod_line
      no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.

         if pih_promo2 = "B" then do on endkey undo, leave:
            find pi_mstr where pi_list_id = pih_list_id
            no-lock no-error.
            if available pi_mstr then do:
               cmtindx = pi_mstr.pi_cmtindx.
               {gprun.i ""gpcmmt04.p"" "(input ""pi_mstr"")"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end.
         end. /* contain bonus stock price list */
      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /*  for each pih_hist  */

      if not sngl_ln then down 1 with frame c.

   end. /* mainloop */

end. /* linefmt */
{&SQQOMTA-P-TAG7}

if sngl_ln then hide frame d.
hide frame c.
hide frame a.
